package com.qf.fmall2202.index.controller;

import com.qf.fmall2202.index.entity.Category;
import com.qf.fmall2202.index.entity.IndexImg;
import com.qf.fmall2202.index.service.ICategoryService;
import com.qf.fmall2202.index.service.IIndexImgService;
import com.qf.fmall2202.product.entity.Product;
import com.qf.fmall2202.product.service.IProductService;
import com.qf.fmall2202.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 轮播图  前端控制器
 * </p>
 *
 * @author dong_
 * @since 2022-11-07
 */
@CrossOrigin
@RestController
@RequestMapping("/index")
public class IndexImgController {

    @Autowired
    IIndexImgService indexImgService;

    @Autowired
    ICategoryService categoryService;

    @Autowired
    IProductService productService;

    @GetMapping("/indeximg")
    public R indeximg(){

        List<IndexImg> data = indexImgService.getIndexImg();

        return R.ok().put("data", data);

    }

    @GetMapping("/category-list")
    public R categoryList(){

        List<Category> data =  categoryService.categoryList();

        return R.ok().put("data", data);

    }

    @GetMapping("/list-recommends")
    public R listRecommends(){
        List<Product> data = productService.listRecommends();
        return R.ok().put("data", data);
    }


    @GetMapping("/category-recommends")
    public R categoryRecommends(){

        List<Category> data = categoryService.categoryRecommends();
        return R.ok().put("data", data);

    }

}
